/* eslint-disable no-shadow */
export function count({ search }) {
  return RSocket.rr({
    route: 'rsorders.count',
    args: { search },
  });
}

export function search({ search, pg }) {
  return RSocket.rs({
    route: 'rsorders',
    args: { search, pg, sort: ['upDate;desc'] },
  });
}

export function ordersSearchCount({ search }) {
  return RSocket.rr({
    route: 'orders.search.count',
    args: { search: { ...search, orderType: 4 } },
  });
}

export function ordersSearch({ search, pg }) {
  return RSocket.rs({
    route: 'orders.search',
    args: { search: { ...search, orderType: 4 }, pg, sort: ['upDate;desc'] },
  });
}

/**
 * @func 获取指定的班车订单
 * @param {string} id 订单id
 */
export function get(id) {
  return RSocket.rr({
    route: `rsorders.${id}`,
  });
}

/**
 * @func 修改拼车订单
 * @param {object} order
 */
export function update(order) {
  return RSocket.rr({
    route: 'rsorders.update',
    data: order,
  });
}

/**
 * @param {*} param0
 * @returns
 */
export function partners({ search, page }) {
  return RSocket.rs({
    route: 'partners',
    args: {
      search,
      pg: { page, sort: ['partnerInfo.registerTime;desc'] },
    },
  });
}

/**
 * @func 日志流水分页条件查询
 * @param {}
 */
export function getLogs({ search }) {
  return RSocket.rs({
    route: 'logs',
    args: {
      search,
      pg: { page: 0, size: 100, sort: ['ts;desc'] },
    },
  });
}


/**
 * 订单发起申请退款
 * @param {*} id 订单id
 * @param {*} data 请求数据
 * @returns true
 */
export function orderSponsorRefund(id, data, args) {
  return RSocket.rr({
    route: `orders.${id}.application.refund`,
    args: {
      ...args,
    },
    data: [
      data,
    ],
  });
}

/**
 * 订单发起线下支付
 * @param {*} data 请求数据
 * @returns true
 */
export function orderOfflineSubmit(data) {
  return RSocket.rr({
    route: 'pay.offline-payments.submit',
    data: {
      ...data,
    },
  });
}

/**
 * 订单发起线下支付 后端中间件
 * @param {*} data 请求数据
 * @returns true
 */
export function orderCreateOffline(data) {
  return RSocket.rr({
    route: 'cbv.offline.add.refund',
    data: {
      ...data,
    },
  });
}

/**
 * 获取该车票下的订单信息
 * @param {*} id 订单id
 * @returns true
 */
export function getIdRefund(id) {
  return RSocket.rs({
    route: `orders.${id}.get.refund`,
  });
}

/**
 * 获取该车票下的订单信息
 * @param {*} id 订单id
 * @returns true
 */
export function getOrderTicket({ search, pg }) {
  return RSocket.rs({
    route: 'cbv.applications',
    args: {
      search: {
        ...search,
        orderType: 4,
      },
      pg,
    },
  });
}

/**
 * 获取该车票下的订单信息
 * @param {*} id 订单id
 * @returns true
 */
export function getOrderTicketCount({ search }) {
  return RSocket.rr({
    route: 'cbv.applications.count',
    args: {
      search: {
        ...search,
        orderType: 4,
      },
    },
  });
}

/**
 * 取消订单中的申请退款
 * @param {*} data 请求参数
 * @returns true
 */
export function orderCancelRefund(data) {
  return RSocket.rr({
    route: 'orders.cancel.refund',
    args: {
      ...data,
    },
  });
}

/**
 * 取消订单中的申请退款
 * @param {*} data 请求参数
 * @returns true
 */
export function orderCommitRefund(data) {
  return RSocket.rr({
    route: 'orders.commit.refund',
    args: {
      ...data,
    },
  });
}

/**
 * 修改订单中的申请退款
 * @param {*} data 请求参数
 * @returns true
 */
export function orderRefundUpdate(data) {
  return RSocket.rr({
    route: 'cbv.applications.update',
    data: {
      ...data,
    },
  });
}

/**
 * 修改订单中的申请退款
 * @param {*} args 请求参数
 * @returns true
 */
export function getOrderRefundTicket(args) {
  return RSocket.rs({
    route: 'orders.get.refund.ticket',
    args: {
      ...args,
    },
  });
}

/**
 * 手动同步巴士状态
 */
export function syncScOrder() {
  return RSocket.rr({
    route: 'services.update.ticket.status',
  });
}

/**
 * 查询分账方
 * @param {*} orderId 订单id
 * @returns true
 */
export function getAccount(orderId) {
  return RSocket.rs({
    route: `orders.${orderId}.account.info`,
    args: {
      directRoute: false,
    },
  });
}

/**
 * 获取该订单所有车票对应已退款金额
 * @param {*} orderId 订单id
 * @returns true
 */
export function getTicketRefunds(orderId) {
  return RSocket.rr({
    route: `cbv.applications.${orderId}.tickets.refund.amount`,
  });
}

/**
 * 获取订单优惠信息
 * @param {*} id
 * @returns
 */
export function getOrderDiscountInfo(args) {
  return RSocket.rs({
    route: 'cbv.applications.order.discount.info',
    args: {
      ...args,
    },
  });
}

/**
 * 取消订单
 */
export function orderCancel(args) {
  return RSocket.rr({
    route: 'orders.cancel',
    args,
  });
}

/**
 * 取消订单
 */
export function orderEnableShare(args) {
  return RSocket.rr({
    route: 'orders.enable.order.share',
    args,
  });
}

/**
 * 获取收款方
 */
export function getOrderPayee(args) {
  return RSocket.rr({
    route: 'pay.trans.payee',
    args,
  });
}
